//
//  NSArrayBlocksSupportTest.m
//  HigherOrderMessaging
//
//  Created by Ofri Wolfus on 14/12/06.
//  Copyright 2006 Ofri Wolfus. All rights reserved.
//

#import "NSArrayBlocksSupportTest.h"
#import <HigherOrderMessaging/Block.h>


@implementation NSArrayBlocksSupportTest

- (void)testSimpleBlock {
	NSArray *arr = [NSArray arrayWithObjects:@"a", @"b", @"aa", nil];
	unsigned i = 0U;
	NSMutableArray *r = [NSMutableArray array];
	
	/*[arr foreach:DPBlock(
						 NSLog(@"%@", each);
						 NSLog(@"%d", i);
						 ++i;
						 if ([each hasPrefix:@"a"])
							[r addObject:each];
						 )];*/
	DPBlock *b;
	b = ({ 
		__label__ __dp_block_start, __dp_block_return; 
		DPBlock *_block = DPCreateBlock(&&__dp_block_start, __builtin_apply_args(), 
										method_getSizeOfArguments(dp_getMethod(self, _cmd))); 
		goto __dp_block_return; 
__dp_block_start: 
	NSLog(@"%d", i);
++i;
	//goto *__dp_block_finish; 
	return;
	__dp_block_return: 
	_block; 
	});
	[arr foreach:b];

	NSLog(@"r = %@", r);
}

- (unsigned)numberOfIterations {
	return 1U;
}

@end
